package Pieces;

import java.util.LinkedList;
import java.util.List;

public class PieceFactory {
	public static Piece createKing(PiecePlayerEnum col,int posRow, int posCol){
		Piece king = new Piece(col,'K',posRow,posCol);
		List<MoveDirections> moves = new LinkedList<MoveDirections>();
		
		moves.add(MoveDirections.NO);
		moves.add(MoveDirections.NE);
		moves.add(MoveDirections.EA);
		moves.add(MoveDirections.SE);
		moves.add(MoveDirections.SO);
		moves.add(MoveDirections.SW);
		moves.add(MoveDirections.WE);
		moves.add(MoveDirections.NW);

		king.setPossibleMoves(moves);
		return king;
	}
	
	public static Piece createPawn(PiecePlayerEnum col,int posRow, int posCol){
		Piece pawn = new Piece(col,'P',posRow,posCol);
		List<MoveDirections> moves = new LinkedList<MoveDirections>();
		
		if (pawn.isWhite()){
			moves.add(MoveDirections.NO);
		} else {
			moves.add(MoveDirections.SO);
		}

		pawn.setPossibleMoves(moves);
		return pawn;
	}
	
	public static Piece createBishop(PiecePlayerEnum col,int posRow, int posCol){
		Piece bishop = new Piece(col,'B',posRow,posCol);
		List<MoveDirections> moves = new LinkedList<MoveDirections>();
		
		moves.add(MoveDirections.NE);
		moves.add(MoveDirections.SE);
		moves.add(MoveDirections.SW);
		moves.add(MoveDirections.NW);

		bishop.setPossibleMoves(moves);
		return bishop;
	}
	
	public static Piece createRook(PiecePlayerEnum col,int posRow, int posCol){
		Piece rook = new Piece(col,'R',posRow,posCol);
		List<MoveDirections> moves = new LinkedList<MoveDirections>();
		
		moves.add(MoveDirections.NO);
		moves.add(MoveDirections.EA);
		moves.add(MoveDirections.SO);
		moves.add(MoveDirections.WE);

		rook.setPossibleMoves(moves);
		return rook;
	}
	
	public static Piece createGeneral(PiecePlayerEnum col,int posRow, int posCol){
		Piece general = new Piece(col,'G',posRow,posCol);
		List<MoveDirections> moves = new LinkedList<MoveDirections>();
		
		if (general.isWhite()){
			moves.add(MoveDirections.NE);
			moves.add(MoveDirections.NE);
			moves.add(MoveDirections.EA);
			moves.add(MoveDirections.SO);
			moves.add(MoveDirections.WE);
			moves.add(MoveDirections.NW);
		} else {
			moves.add(MoveDirections.NO);
			moves.add(MoveDirections.EA);
			moves.add(MoveDirections.SE);
			moves.add(MoveDirections.SO);
			moves.add(MoveDirections.SW);
			moves.add(MoveDirections.WE);
		}

		general.setPossibleMoves(moves);
		return general;
	}
}
